import request from '@/utils/request'
import type {
  HospitalResponseData,
  HospitalLevelAndRegionResponseData,
  HospitalSearchListResponseData
} from './type'
enum API {
  GETHOSPITALLIST_URL = '/api/hosp/hospital/',
  GETLEVELANDREGION_URL = '/api/cmn/dict/findByDictCode/',
  GETSEARCHLIST_URL = '/api/hosp/hospital/findByHosname/'
}

// 获取医院数据
export const getHospitalListService = (
  page: number,
  limit: number,
  hostype = '',
  districtCode = ''
) =>
  request.get<any, HospitalResponseData>(
    API.GETHOSPITALLIST_URL + `${page}/${limit}`,
    {
      params: {
        hostype,
        districtCode
      }
    }
  )

// 获取医院等级和地区信息
export const getHospitalLevelAndRegionService = (dictCode: string) =>
  request.get<any, HospitalLevelAndRegionResponseData>(
    API.GETLEVELANDREGION_URL + dictCode
  )

// 获取搜索框医院列表
export const getHospitalSearchListService = (hosname: string) =>
  request.get<any, HospitalSearchListResponseData>(
    API.GETSEARCHLIST_URL + hosname
  )
